<template>
	<div>
		<main-content
			v-if="pageType === 'i'"
			:tableHeight.sync="tableHeight"
			:otherDependenComponents="otherDependenComponents"
		>
			<template slot="query">
				<el-form
					ref="queryForm"
					:inline="true"
					:model="queryData"
					class="flex-warp-container"
				>
					<el-form-item
						:label="`${$t('common.belong_merchant')}:`"
						prop="merchantId"
						class="flex-row-container"
						label-width="77px"
					>
						<merchant-select
							v-model="queryData.merchantId"
						></merchant-select>
					</el-form-item>
					<el-form-item
						label="结算周期:"
						class="flex-row-container"
						label-width="77px"
					>
						<el-date-picker
							v-model="queryTime"
							size="medium"
							:picker-options="pickerShortcut2"
							format="yyyy-MM-dd"
							type="daterange"
							range-separator="-"
							:start-placeholder="$t('common.start_time')"
							:end-placeholder="$t('common.end_time')"
							align="right"
							:clearable="false"
							:default-time="defaultTime"
						></el-date-picker>
					</el-form-item>
					<el-form-item
						:label="`${$t('funds.fund_audit.order_status')}:`"
						prop="orderStatus"
						class="flex-row-container"
						label-width="77px"
					>
						<el-select
							v-model="queryData.orderStatus"
							style="width: 220px"
							clearable
							:placeholder="$t('common.select_all')"
						>
							<el-option
								v-for="item in orderStatusArr"
								:key="item.code"
								:label="item.description"
								:value="item.code"
							></el-option>
						</el-select>
					</el-form-item>
					<el-form-item
						label="业务模式:"
						class="flex-row-container"
						label-width="77px"
					>
						<el-select
							v-model="queryData.businessModel"
							size="medium"
							:placeholder="$t('common.select_all')"
							style="width: 200px"
							clearable
						>
							<el-option
								v-for="item in businessModelList"
								:key="item.code"
								:label="item.description"
								:value="item.code"
							></el-option>
						</el-select>
					</el-form-item>
					<el-form-item
						:label="$t('report.agency_level')"
						class="flex-row-container"
						label-width="77px"
					>
						<el-select
							v-model="queryData.proxyLevel"
							size="medium"
							:placeholder="$t('common.select_all')"
							clearable
							multiple
							collapse-tags
						>
							<el-option
								v-for="item in proxyleveList"
								:key="item.id"
								:label="item.id"
								:value="item.id"
							></el-option>
						</el-select>
					</el-form-item>
					<el-form-item class="flex-row-container">
						<el-input
							v-model="queryData.inputValue"
							class="input-with-select"
							:placeholder="$t('common.please_enter')"
							clearable
							size="medium"
							@input="forceUpdate"
						>
							<el-select
								slot="prepend"
								v-model="queryData.inputType"
								width="110px"
								:placeholder="$t('common.please_choose')"
							>
								<el-option
									:label="$t('funds.proxy_name')"
									:value="1"
								></el-option>

								<el-option
									:label="
										$t('funds.fund_audit.top_proxy_name')
									"
									:value="2"
								></el-option>
								<el-option
									:label="$t('funds.order_no')"
									:value="3"
								></el-option>
							</el-select>
						</el-input>
					</el-form-item>
					<!-- <el-form-item :label="`${$t('funds.order_no')}:`" prop="orderNo">
						<el-input
							v-model="queryData.orderNo"
							clearable
							size="medium"
							style="width: 260px"
							:placeholder="$t('common.please_enter')"
							@blur="cleanBlankSpace('queryData', 'orderNo')"
						></el-input>
					</el-form-item>
					<el-form-item label="总代理账号:">
						<el-input
							v-model="queryData.topProxyName"
							clearable
							size="medium"
							style="width: 300px"
							:placeholder="$t('common.please_enter')"
							@blur="cleanBlankSpace('queryData', 'topProxyName')"
						></el-input>
					</el-form-item>
					<el-form-item :label="$t('funds.proxy_name')">
						<el-input
							v-model="queryData.proxyName"
							clearable
							size="medium"
							style="width: 220px"
							:placeholder="$t('common.please_enter')"
							@blur="cleanBlankSpace('queryData', 'proxyName')"
						></el-input>
					</el-form-item> -->
					<el-form-item
						label="实发收益:"
						prop="lockAccount"
						class="flex-row-container"
						label-width="77px"
					>
						<el-input
							v-model="queryData.minIncomeAmount"
							size="normal"
							clearable
							style="width: 130px"
							:placeholder="$t('common.minimum')"
							maxLength="15"
							v-input="{ name: 'onlyTwoNum' }"
							name="minIncomeAmount"
							@blur="
								handleAmount(
									queryData,
									1,
									'minIncomeAmount',
									'maxIncomeAmount',
									$t(
										'funds.proxy_member_funds_record.form_search_rebateCheck1'
									)
								)
							"
						></el-input>
						-
						<el-input
							v-model="queryData.maxIncomeAmount"
							size="normal"
							clearable
							style="width: 130px"
							:placeholder="$t('common.maximum')"
							maxLength="15"
							v-input="{ name: 'onlyTwoNum' }"
							name="maxIncomeAmount"
							@blur="
								handleAmount(
									queryData,
									2,
									'minIncomeAmount',
									'maxIncomeAmount',
									$t(
										'funds.proxy_member_funds_record.form_search_rebateCheck2'
									)
								)
							"
						></el-input>
					</el-form-item>
					<el-form-item style="margin-left: 8px">
						<el-button
							type="primary"
							icon="el-icon-search"
							:disabled="loading"
							:loading="loading"
							size="medium"
							@click="search"
						>
							{{ $t('common.search') }}
						</el-button>
						<el-button
							icon="el-icon-refresh-left"
							:disabled="loading"
							size="medium"
							@click="reset"
						>
							{{ $t('common.reset') }}
						</el-button>
						<!-- <el-button
							type="success"
							icon="el-icon-sort"
							:disabled="loading"
							size="medium"
							@click="openColSettings"
						>
							{{ $t('common.row_set') }}
						</el-button> -->
					</el-form-item>
				</el-form>
			</template>
			<template slot="content">
				<el-table
					v-loading="loading"
					element-loading-spinner="el-icon-loading"
					border
					size="mini"
					class="small-size-table"
					:data="tableData"
					style="width: 100%"
					highlight-current-row
					:header-cell-style="getRowClass"
					:max-height="tableHeight"
				>
					<el-table-column
						prop="orderNo"
						align="center"
						:label="$t('funds.order_no')"
						min-width="280"
						show-overflow-tooltip
					>
						<template slot-scope="scope">
							<Copy :title="scope.row.orderNo" :copy="copy">
								{{ scope.row.orderNo }}
							</Copy>
						</template>
					</el-table-column>
					<el-table-column
						align="center"
						label="结算周期"
						min-width="200"
						show-overflow-tooltip
					>
						<template slot-scope="scope">
							{{
								getRebateCycle(
									scope.row.startTime,
									scope.row.endTime
								)
							}}
							<!-- {{ scope.row.startTime }} - {{  scope.row.endTime }} -->
						</template>
					</el-table-column>
					<el-table-column
						prop="proxyName"
						align="center"
						:label="$t('funds.proxy_name')"
						min-width="150"
						show-overflow-tooltip
					>
						<template slot-scope="scope">
							<Copy :title="scope.row.proxyName" :copy="copy">
								{{ scope.row.proxyName }}
							</Copy>
						</template>
					</el-table-column>
					<el-table-column
						prop="proxyName"
						align="center"
						label="业务模式"
						min-width="150"
						show-overflow-tooltip
					>
						<template slot-scope="scope">
							<span>
								{{
									mappingBusinessModel(
										scope.row.businessModel
									)
								}}
							</span>
						</template>
					</el-table-column>
					<el-table-column
						prop="proxyLevel"
						align="center"
						:label="
							$t(
								'funds.proxy_member_funds_record.proxy_level_name'
							)
						"
						min-width="150"
						show-overflow-tooltip
					>
						<template slot-scope="scope">
							{{ scope.row.proxyLevel }}
						</template>
					</el-table-column>
					<el-table-column
						prop="proxyLevelName"
						align="center"
						label="收益比例"
						min-width="150"
						show-overflow-tooltip
					>
						<template slot-scope="scope">
							<span style="visibility:visible;">
								<el-link
									class="lightBlueColor"
									type="primary"
									@click="dialogData(scope.row, 0)"
								>
									查看
								</el-link>
							</span>
						</template>
					</el-table-column>

					<el-table-column
						prop="merchantName"
						align="center"
						:label="
							$t(
								'funds.proxy_member_funds_record.parent_proxy_account'
							)
						"
						min-width="150"
						show-overflow-tooltip
					>
						<template slot-scope="scope">
							<span v-if="scope.row.parentProxyName === '-'">
								{{ scope.row.parentProxyName }}
							</span>
							<Copy
								v-else
								:title="scope.row.parentProxyName"
								:copy="copy"
							>
								{{ scope.row.parentProxyName }}
							</Copy>
						</template>
					</el-table-column>
					<el-table-column
						prop="topProxyName"
						align="center"
						:label="
							$t('funds.proxy_member_funds_record.top_proxy_name')
						"
						min-width="150"
						show-overflow-tooltip
					>
						<template slot-scope="scope">
							<Copy :title="scope.row.topProxyName" :copy="copy">
								{{ scope.row.topProxyName }}
							</Copy>
						</template>
					</el-table-column>

					<!-- <el-table-column
							prop="merchantName"
							align="center"
							:label="$t('common.belong_merchant')"
							min-width="150"
							show-overflow-tooltip
						>
							<template slot-scope="scope">
								{{ merchantFilter(scope.row.merchantId) }}
							</template>
						</el-table-column> -->

					<el-table-column
						prop="dxServiceFeeRebateAmount"
						align="center"
						label="德州俱乐部服务费分成"
						show-overflow-tooltip
						min-width="200"
					>
						<template slot-scope="scope">
							<p
								:style="
									handleNumberColor(
										scope.row.dxServiceFeeRebateAmount
									)
								"
							>
								<el-link
									class="lightBlueColor"
									type="primary"
									@click="dialogData(scope.row, 1)"
								>
									{{
										handleTotalNumber(
											'USDT',
											scope.row.dxServiceFeeRebateAmount
										)
									}}
								</el-link>
							</p>
						</template>
					</el-table-column>
					<el-table-column
						prop="dxInsurancePartsAmount"
						align="center"
						label="德州保险盈亏分成"
						show-overflow-tooltip
						min-width="200"
					>
						<template slot-scope="scope">
							<p
								:style="
									handleNumberColor(
										scope.row.dxInsurancePartsAmount
									)
								"
							>
								<el-link
									class="lightBlueColor"
									type="primary"
									@click="dialogData(scope.row, 2)"
								>
									{{
										handleTotalNumber(
											'USDT',
											scope.row.dxInsurancePartsAmount
										)
									}}
								</el-link>
							</p>
						</template>
					</el-table-column>
					<el-table-column
						prop="dxInsurancePartsAmount"
						align="center"
						label="德州增值服务分成"
						show-overflow-tooltip
						min-width="200"
					>
						<template slot-scope="scope">
							<p
								:style="
									handleNumberColor(
										scope.row.valueAddedTotalAmount
									)
								"
							>
								<el-link
									class="lightBlueColor"
									type="primary"
									@click="dialogData(scope.row, 5)"
								>
									{{
										handleTotalNumber(
											'USDT',
											scope.row.valueAddedTotalAmount
										)
									}}
								</el-link>
							</p>
						</template>
					</el-table-column>
					<el-table-column
						prop="otherVenueRebateAmount"
						align="center"
						label="其他场馆代理返点"
						show-overflow-tooltip
						min-width="200"
					>
						<template slot-scope="scope">
							<p
								:style="
									handleNumberColor(
										scope.row.otherVenueRebateAmount
									)
								"
							>
								<el-link
									class="lightBlueColor"
									type="primary"
									@click="dialogData(scope.row, 3)"
								>
									{{
										handleTotalNumber(
											'USDT',
											scope.row.otherVenueRebateAmount
										)
									}}
								</el-link>
							</p>
						</template>
					</el-table-column>
					<el-table-column
						prop="otherVenuePartsAmount"
						align="center"
						label="其他场馆盈亏占成"
						show-overflow-tooltip
						min-width="200"
					>
						<template slot-scope="scope">
							<p
								v-if="scope.row.billFlag"
								:style="
									handleNumberColor(
										scope.row.otherVenuePartsAmount
									)
								"
							>
								<el-link
									class="lightBlueColor"
									type="primary"
									@click="dialogData(scope.row, 4)"
								>
									{{
										handleTotalNumber(
											'USDT',
											scope.row.otherVenuePartsAmount
										)
									}}
								</el-link>
							</p>
							<p v-else style="color:#CCCCCC;">
								{{
									handleTotalNumber(
										'USDT',
										scope.row.otherVenuePartsAmount
									)
								}}
							</p>
						</template>
					</el-table-column>
					<el-table-column
						prop="currentIncomeAmount"
						align="center"
						label="本期收益"
						show-overflow-tooltip
						min-width="200"
					>
						<template slot-scope="scope">
							<p>
								{{
									handleTotalNumber(
										'USDT',
										scope.row.currentIncomeAmount
									)
								}}
							</p>
						</template>
					</el-table-column>
					<el-table-column
						prop="adjustIncomeAmount"
						align="center"
						label="收益调整"
						show-overflow-tooltip
						min-width="200"
					>
						<template slot-scope="scope">
							<p
								:style="
									handleNumberColor(
										scope.row.adjustIncomeAmount
									)
								"
							>
								{{
									handleTotalNumber(
										'USDT',
										scope.row.adjustIncomeAmount
									)
								}}
							</p>
						</template>
					</el-table-column>
					<el-table-column
						prop="realIncomeAmount"
						align="center"
						label="调整后收益"
						show-overflow-tooltip
						min-width="200"
					>
						<template slot-scope="scope">
							<p>
								{{
									handleTotalNumber(
										'USDT',
										scope.row.realIncomeAmount
									)
								}}
							</p>
						</template>
					</el-table-column>

					<el-table-column
						prop="orderStatus"
						align="center"
						:label="$t('funds.fund_audit.order_status')"
						:width="getWidth(140, 1.4)"
					>
						<template slot-scope="scope">
							<el-tag
								:type="
									scope.row.auditStatus == 4
										? 'success'
										: 'danger'
								"
							>
								{{
									orderStatusMap[scope.row.auditStatus] || '-'
								}}
							</el-tag>
						</template>
					</el-table-column>

					<el-table-column
						align="center"
						:label="$t('funds.fund_audit.audit_time')"
						width="220"
						show-overflow-tooltip
					>
						<template slot-scope="scope">
							<p>
								{{ $t('funds.fund_audit.audit_text_1') }}：{{
									scope.row.audit1Time || '-'
								}}
							</p>
							<p v-if="scope.row.audit1Result === 1">
								{{ $t('funds.fund_audit.audit_text_2') }}：{{
									scope.row.audit2Time || '-'
								}}
							</p>
						</template>
					</el-table-column>
					<el-table-column
						align="center"
						:label="$t('funds.fund_audit.audit_cost')"
						width="150"
						show-overflow-tooltip
					>
						<template slot-scope="scope">
							<p>
								{{ $t('funds.fund_audit.audit_text_1') }}：{{
									timeTurner(scope.row.audit1Cost) || '-'
								}}
							</p>
							<p v-if="scope.row.audit1Result === 1">
								{{ $t('funds.fund_audit.audit_text_2') }}：{{
									timeTurner(scope.row.audit2Cost) || '-'
								}}
							</p>
						</template>
					</el-table-column>
					<el-table-column
						align="center"
						:label="$t('funds.fund_audit.lock_account')"
						width="220"
						show-overflow-tooltip
					>
						<template slot-scope="scope">
							<p>
								{{ $t('funds.fund_audit.audit_text_1') }}：{{
									scope.row.audit1Operator || '-'
								}}
							</p>
							<p v-if="scope.row.audit1Result == 1">
								{{ $t('funds.fund_audit.audit_text_2') }}：{{
									scope.row.audit2Operator || '-'
								}}
							</p>
						</template>
					</el-table-column>
					<el-table-column
						prop="auditStep"
						align="center"
						:label="$t('common.actions')"
						min-width="150"
					>
						<template slot-scope="scope">
							<el-button
								v-if="hasPermission('90600046')"
								type="primary"
								size="medium"
								@click="openDetail(scope.row)"
							>
								{{ $t('common.check') }}
							</el-button>
							<span v-else>-</span>
						</template>
					</el-table-column>
				</el-table>
				<!-- 分页 -->
				<el-pagination
					v-show="!!total"
					:current-page.sync="pageNum"
					class="pageValue"
					background
					layout="total, sizes,prev, pager, next, jumper"
					:page-size="pageSize"
					:page-sizes="pageSizes"
					:total="total"
					:pager-count="9"
					@current-change="handleCurrentChange"
					@size-change="handleSizeChange"
				></el-pagination>
			</template>
		</main-content>
		<detail
			v-if="pageType === 'd'"
			:detail-data="detailData"
			@goBack="goBack"
		></detail>
		<el-dialog
			:title="$t('common.row_set')"
			center
			:visible.sync="colSettings.visible"
			width="475px"
			class="setting-div"
		>
			<div>
				<el-link type="primary" class="mb15" @click="clickDel">
					复原缺省
				</el-link>
			</div>
			<div
				v-for="(value, name1) in activityListField"
				:key="name1"
				class="setting-div"
			>
				<el-checkbox v-model="dialogColumnData[name1]">
					{{ name1 }}
				</el-checkbox>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button @click="colSettings.visible = false">
					{{ $t('common.cancel') }}
				</el-button>
				<el-button type="primary" @click="handleOrderList">
					{{ $t('common.submit') }}
				</el-button>
			</div>
		</el-dialog>

		<!-- 收益比例弹窗 -->
		<IncomeDetailDialog
			v-if="incomeDetailDialogVisible"
			:visible.sync="incomeDetailDialogVisible"
			@handleVisible="incomeDetailDialogVisible = false"
			:curData="curData"
		/>

		<!-- 德州服务费返点弹窗 -->
		<AuditDetailDialog1
			v-if="auditDetailDialogVisible1"
			:visible.sync="auditDetailDialogVisible1"
			@handleVisible="auditDetailDialogVisible1 = false"
			:curData="curData"
		/>

		<!-- 德州保险分成弹窗 -->
		<AuditDetailDialog2
			v-if="auditDetailDialogVisible2"
			:visible.sync="auditDetailDialogVisible2"
			@handleVisible="auditDetailDialogVisible2 = false"
			:curData="curData"
		/>

		<!-- 其他场馆返点弹窗 -->
		<AuditDetailDialog3
			v-if="auditDetailDialogVisible3"
			:visible.sync="auditDetailDialogVisible3"
			@handleVisible="auditDetailDialogVisible3 = false"
			:curData="curData"
		/>

		<!-- 其他场馆分成弹窗 -->
		<AuditDetailDialog4
			v-if="auditDetailDialogVisible4"
			:visible.sync="auditDetailDialogVisible4"
			@handleVisible="auditDetailDialogVisible4 = false"
			:curData="curData"
		/>

		<!-- 增值分成弹窗 -->
		<AuditDetailDialog5
			v-if="auditDetailDialogVisible5"
			:visible.sync="auditDetailDialogVisible5"
			@handleVisible="auditDetailDialogVisible5 = false"
			:curData="curData"
		/>
	</div>
</template>

<script>
import list from '@/mixins/list'
import dayjs from 'dayjs'
import { getUsername } from '@/utils/auth'
import { NO_SPECIAL_CHAR } from '@/utils/pattern'
import MainContent from '@/components/MainContent/index.vue'
import IncomeDetailDialog from '@/components/Funds/ProxyIncome/incomeDetailDialog.vue'
import AuditDetailDialog1 from '@/components/Funds/ProxyIncome/auditDetailDialog1.vue'
import AuditDetailDialog2 from '@/components/Funds/ProxyIncome/auditDetailDialog2.vue'
import AuditDetailDialog3 from '@/components/Funds/ProxyIncome/auditDetailDialog3.vue'
import AuditDetailDialog4 from '@/components/Funds/ProxyIncome/auditDetailDialog4.vue'
import AuditDetailDialog5 from '@/components/Funds/ProxyIncome/auditDetailDialog5.vue'
const end = () => {
	return dayjs()
		.add(-1, 'day')
		.endOf('day')
		.valueOf()
}
const start = () => {
	return dayjs()
		.add(-1, 'day')
		.startOf('day')
		.valueOf()
}
import { routerNames } from '@/utils/consts'
export default {
	name: routerNames.rebateCheckRecord,
	components: {
		detail: () => import('./components/detail'),
		MainContent,
		IncomeDetailDialog,
		AuditDetailDialog1,
		AuditDetailDialog2,
		AuditDetailDialog3,
		AuditDetailDialog4,
		AuditDetailDialog5
	},
	mixins: [list],
	data() {
		return {
			tableHeight: 480,
			otherDependenComponents: [],
			queryData: {
				inputType: 1,
				minIncomeAmount: undefined,
				maxIncomeAmount: undefined
			},
			queryTime: [start(), end()],
			pageType: 'i',
			detailData: {},
			proxyleveList: [],
			businessModelList: [
				{
					description: '现金业务',
					code: '1'
				},
				{
					description: '信用业务',
					code: '2'
				}
			],
			showClear1: false,
			showClear2: false,
			curData: {},
			incomeDetailDialogVisible: false,
			auditDetailDialogVisible1: false,
			auditDetailDialogVisible2: false,
			auditDetailDialogVisible3: false,
			auditDetailDialogVisible4: false,
			auditDetailDialogVisible5: false,
			name: '',
			tableData: [],
			selectedData: {
				type: 1,
				userName: ''
			},
			orderStatusArr: [
				{
					code: '4',
					description: this.$t('funds.fund_audit.pass_the_audit')
				},
				{
					description: this.$t('funds.fund_audit.audit_fail_1'),
					code: '1'
				},
				{
					code: '3',
					description: this.$t('funds.fund_audit.audit_fail_2')
				}
			],
			orderStatusMap: {
				1: this.$t('funds.fund_audit.audit_fail_1'),
				3: this.$t('funds.fund_audit.audit_fail_2'),
				4: this.$t('funds.fund_audit.pass_the_audit')
			},
			colSettings: {
				visible: false,
				dialogColumnData: {}
			},
			activityListField: {
				// 返点周期: true,
				// 代理账号: true,
				// 所属商户: true,
				// 返点金额: true,
				// 订单状态: true,
				// 审核时间: true,
				// 审核用时: true,
				// 审核人: true,
				// 操作: true
				[this.$t('funds.fund_audit.rebates_cycle')]: true,
				[this.$t(
					'funds.proxy_member_funds_record.top_proxy_name'
				)]: true,
				[this.$t('funds.proxy_name')]: true,
				[this.$t('common.belong_merchant')]: true,
				[this.$t(
					'funds.proxy_member_funds_record.person_rebate_amount'
				)]: true,
				[this.$t('funds.fund_audit.order_status')]: true,
				[this.$t('funds.fund_audit.audit_time')]: true,
				[this.$t('funds.fund_audit.audit_cost')]: true,
				[this.$t('funds.fund_audit.lock_account')]: true,
				[this.$t('common.actions')]: true
			}
		}
	},
	computed: {},
	created() {
		this.initIndexDB('rebateCheckRecord', this.activityListField)
		this.getProxyleve()
	},
	mounted() {
		this.name = getUsername()
	},
	methods: {
		getProxyleve() {
			this.$api.getProxylevelnameList().then((res) => {
				this.proxyleveList = res.data || []
			})
		},
		forceUpdate(value) {
			this.$forceUpdate()
			this.queryData.inputValue = this.queryData.inputValue.replace(
				/[^A-Za-z0-9]/g,
				''
			)
		},
		hiddenClearIcon(key) {
			setTimeout(() => {
				this[key] = false
			}, 200)
		},
		clearable(key) {
			this.$delete(this.queryData, key)
		},
		cleanBlankSpace(key, key1) {
			if (this[key][key1]) {
				this[key][key1] = (this[key][key1] + '').replace(
					/[\u4E00-\u9FA5]/g,
					''
				)
				this[key][key1] = (this[key][key1] + '').replace(
					NO_SPECIAL_CHAR,
					''
				)
			}
		},
		timeTurner(time) {
			var day = Math.floor(time / 86400) // 整数部分代表的是天；一天有24*60*60=86400秒 ；

			time = time % 86400 // 余数代表剩下的秒数；

			var hour = Math.floor(time / 3600) // 整数部分代表小时；

			time %= 3600 // 余数代表 剩下的秒数；

			var minute = Math.floor(time / 60)

			time %= 60

			var str = `${day > 0 ? day + 'd' : ''}${
				hour > 0 || day ? hour + 'h' : ''
			}${minute > 0 || hour ? minute + 'm' : ''}${time}s`
			return str
		},
		getRebateCycle(date1, date2) {
			date1 = date1 && dayjs(String(date1)).format('YYYY-MM-DD')
			date2 = date2 && dayjs(String(date2)).format('YYYY-MM-DD')

			if (date1 === date2) {
				return date1 || '-'
			} else {
				return date1 && date2 ? date1 + ' - ' + date2 : '-'
			}
		},
		filterOrderStatus(code) {
			const item = this.orderStatusArr.find(
				(item) => item.code === String(code)
			)
			return item ? item.description : '-'
		},
		loadData() {
			this.loading = true
			const [startTime, endTime] = this.queryTime || []
			let params = {
				...this.queryData,
				auditStatus: this.queryData.orderStatus
					? [this.queryData.orderStatus]
					: [1, 3, 4], //0-待一审 1-一审拒绝 2-待二审 3-二审拒绝 4-二审通过
				cycleStartDate: startTime
					? dayjs(startTime)
							.format('YYYY-MM-DD')
							.replace(/\-/g, '')
					: undefined,
				cycleEndDate: endTime
					? dayjs(endTime)
							.format('YYYY-MM-DD')
							.replace(/\-/g, '')
					: undefined
			}
			params = {
				...this.getParams(params)
			}
			if (params.inputType === 1) {
				params.proxyName = params.inputValue || undefined
				params.orderNo = undefined
				params.topProxyName = undefined
			} else if (params.inputType === 2) {
				params.orderNo = undefined
				params.proxyName = undefined
				params.topProxyName = params.inputValue || undefined
			} else {
				params.orderNo = params.inputValue || undefined
				params.proxyName = undefined
				params.topProxyName = undefined
			}
			this.$api
				.proxyIncomeList(params)
				.then((res) => {
					const { record, totalRecord } = res.data || {}
					this.tableData = Array.isArray(record)
						? Object.freeze(record)
						: []
					this.total = totalRecord || 0
					this.loading = false
				})
				.catch(() => {
					this.loading = false
				})
		},
		openDetail(row) {
			this.allowReview = row.lockAccount === this.name
			this.detailData = row
			this.pageType = 'd'
		},
		goBack() {
			this.pageType = 'i'
			this.loadData()
		},
		dialogData(row, i) {
			this.curData = row
			console.log(i, this.curData)
			if (i == 0) {
				this.incomeDetailDialogVisible = true
			} else if (i == 1) {
				this.auditDetailDialogVisible1 = true
			} else if (i == 2) {
				this.auditDetailDialogVisible2 = true
			} else if (i == 3) {
				this.auditDetailDialogVisible3 = true
			} else if (i == 4) {
				this.auditDetailDialogVisible4 = true
			} else if (i == 5) {
				this.auditDetailDialogVisible5 = true
			}
		},
		reset() {
			this.queryData = {
				inputType: 1,
				minIncomeAmount: undefined,
				maxIncomeAmount: undefined
			}
			this.queryTime = [start(), end()]
			this.pageNum = 1
			this.loadData()
		},
		// 提交列设置数据
		handleOrderList() {
			this.colSettings.visible = false
			this.updateIndexDB()
		},
		// 打开列设置弹框
		openColSettings() {
			this.getIndexDB(this.activityListField)
			this.colSettings.visible = true
		},
		clickDel() {
			this.dialogColumnData = {}
			this.dialogColumnData = {
				// 返点周期: true,
				// 代理账号: true,
				// 所属商户: true,
				// 返点金额: true,
				// 订单状态: true,
				// 审核时间: true,
				// 审核用时: true,
				// 审核人: true,
				// 操作: true
				[this.$t('funds.fund_audit.rebates_cycle')]: true,
				[this.$t(
					'funds.proxy_member_funds_record.top_proxy_name'
				)]: true,
				[this.$t('funds.proxy_name')]: true,
				[this.$t('common.belong_merchant')]: true,
				[this.$t(
					'funds.proxy_member_funds_record.person_rebate_amount'
				)]: true,
				[this.$t('funds.fund_audit.order_status')]: true,
				[this.$t('funds.fund_audit.audit_time')]: true,
				[this.$t('funds.fund_audit.audit_cost')]: true,
				[this.$t('funds.fund_audit.lock_account')]: true,
				[this.$t('common.actions')]: true
			}
		}
	}
}
</script>

<style lang="scss" scoped>
::v-deep .el-dialog__header {
	text-align: center;
	color: #909399;
	font-weight: 700;
}
::v-deep .caret-wrapper {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
}
.data-refresh {
	margin-top: 0;
	padding-bottom: 20px;
}
::v-deep .el-input-group__prepend {
	width: 110px;
}
.el-input-number_container {
	display: inline-block;
	position: relative;
	.close_icon {
		position: absolute;
		right: 10px;
		top: 50%;
		transform: translateY(-50%);
		cursor: pointer;
		color: #ccc;
	}
}
</style>
